package com.windy.spring.rest.generic;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.windy.spring.dao.DaoPositionHistory;
import com.windy.spring.data.PositionHistory;

/**
 * Handles requests for the application home page.
 */
@Controller
@Transactional
public class WindersMainController {
	
	@Autowired
    public DaoPositionHistory dph;
	
	private static final Logger logger = LoggerFactory.getLogger(WindersMainController.class);
	
	@RequestMapping(value = "/getDataForNearestPositionGBuser/", method = RequestMethod.GET)
	@ResponseBody
	public List<PositionHistory> getSome(@RequestParam Integer id) {
		List<PositionHistory> resultlist=(List<PositionHistory>) dph.findByNearestPositionGBuser(id, 0, 10, null, null, null);
		return resultlist;
	}
	
	@RequestMapping(value = "/getDataForNearestPositionGBuser/{id}/", method = RequestMethod.GET)
	@ResponseBody
	public List<PositionHistory> getDataForNearestPositionGBuser(@PathVariable int id) {
		List<PositionHistory> resultlist=(List<PositionHistory>) dph.findByNearestPositionGBuser(id, 0, 10, null, null, null);
		return resultlist;
	}
}
